//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.ComponentModel;
using System.Diagnostics.Contracts;
using System.Reflection;

namespace OpenLS.Spreadsheet.UI.Internals
{
    [Obsolete]
    public class OffsetObserver: INotifyPropertyChanged
    {
        public OffsetObserver(Dimension dimension)
        {
            Dimension = dimension;
            dimension.PropertyChanged += row_PropertyChanged; //\\ remove handler when dead
        }

        private readonly Dimension Dimension;


        void row_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Offset")
                notifyPropertyChanged("Offset");

        }

        void notifyPropertyChanged(string propertyName)
        {
            Contract.Requires(GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) != null);
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }

        public double Offset { get { return Dimension.Offset; } }


        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}
